<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增产品分类')" />
    <th:block th:include="include :: bootstrap-fileinput-css"/>
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-partsTypeDetail-add">
            <div class="form-group">    
                <label class="col-sm-3 control-label">类别名称：</label>
                <div class="col-sm-8">
                    <input name="typeName" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">所属一级分类：</label>
                <div class="col-sm-8">
                    <select id="parentId" name="parentId" class="form-control">
                        <option th:each="type:${types}" th:value="${type.id}" th:text="${type.typeName}"></option>
                    </select>
                </div>
            </div>


            <div class="form-group">
                <label class="col-sm-3 control-label is-required">人口销售额比例：</label>
                <div class="col-sm-8">
                    <input name="populationSalesRatio" class="form-control" type="text" required>
                </div>
            </div>


            <div class="form-group">
                <label class="col-sm-3 control-label is-required">销售额定金比例：</label>
                <div class="col-sm-8">
                    <input name="salesPaymentRatio" class="form-control" type="text" required>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label">大区合作政策：</label>
                <div class="col-sm-8">
                    <textarea name="cooperationPolicy" class="form-control"></textarea>
                </div>
            </div>


        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: bootstrap-fileinput-js"/>
    <script th:inline="javascript">
        var prefix = ctx + "zsyh/partsTypeDetail"
        $("#form-partsTypeDetail-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-partsTypeDetail-add').serialize());
            }
        }

        $(".file-upload").fileinput({
            uploadUrl: ctx + 'common/uploadOSS',
            maxFileCount: 1,
            autoReplace: true
        }).on('fileuploaded', function (event, data, previewId, index) {
            $("input[name='" + event.currentTarget.id + "']").val(data.response.url)
        }).on('fileremoved', function (event, id, index) {
            $("input[name='" + event.currentTarget.id + "']").val('')
        })
    </script>
</body>
</html>